/*
 * Copyright (c) 2012.
 * Keerthi Ramachandran
 * You are free to copy/modify/share the programs
 */

package com.kee.example.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * Created with IntelliJ IDEA.
 * User: keerthi
 * Date: 12/8/12
 * Time: 5:33 PM
 * To change this template use File | Settings | File Templates.
 */
public class HibernateUtil {
    private static final SessionFactory SESSION_FACTORY = buildSessionFactory();


    private static SessionFactory buildSessionFactory() {
        try {
            return new Configuration().configure().buildSessionFactory();
        } catch (Throwable throwable) {
            System.err.println("Error when initializing " + throwable);
            throw new ExceptionInInitializerError(throwable);
        }
    }

    public static SessionFactory getSessionFactory() {
        return SESSION_FACTORY;

    }

}
